<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .quotationTable {
        width: 100%;
        border: 0;
        border-collapse: collapse;
    }
    .bottom {
        width: 100%;
        border: 0;
        border-collapse: collapse;
    }
    .quotationTable tr:nth-child(even) {
        background-color: white;
    }
    .bottom tr:nth-child(even) {
        background-color: white;
    }
    .quotationTable td {
        border: 1px solid #000000;;
        text-align: center;
        font-size: 13px;
        letter-spacing: 0px;
        line-height: 150%;
    }
    .bottom td {
        border: 1px solid #000000;;
        text-align: center;
        font-size: 14px;
        letter-spacing: 0px;
        line-height: 150%;
    }
    .quotationTable tbody tr td {
        font-size: 13px;
        text-align: center;
        text-verticle: center;
        line-height: 200%;
    }

    .bottom tbody tr td {
        font-size: 14px;
        text-align :center;
        text-verticle:center;
    }
    .quotationTable thead tr td {
        font-size: 13px;
        font-weight: bold;
        text-align: center;
        text-verticle: center;
    }
    .bottom thead tr td {
        font-size: 14px;
        font-weight: bold;
        text-align :center;
        text-verticle:center;
        line-height: 200%;
    }
    .info-table {
        width: 100%;
        border: 0;
        border-collapse: collapse;
    }
    .info-table tr:nth-child(even) {
        background-color: white;
    }
    .info-table td {
        border: 0px;
        text-align: center;
        font-size: 14px;
        letter-spacing: 0px;
        line-height: 180%;
    }
    .info-table tbody tr td {
        font-size: 14px;
    }
    .info-table thead tr td {
        font-size: 14px;
        font-weight: bold;
    }
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }
    .quotationTable input[type="number"] {
        -moz-appearance: textfield;
    }
    .left-part-2 {
        width: 30%;
    }
    .right-part-2 {
        width: 30%;
    }
    .middle-part {
        width: 40%;
    }
    .help p {
        text-indent: 30px;
    }
    .head-table tr:nth-child(even) {
        background-color: white;
    }
    .bottom tr:nth-child(even) {
        background-color: white;
    }
    .info-p-left {
        margin: 0;
    }
    .info-p-right {
        margin: 0;
    }
</style>
<div class="modal fade" id="modal-confirm">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">驳回报价</h4>
            </div>
            <div class="modal-body">
                <label class="col-sm-12 control-label" style="font-size: 20px; text-align: left">确认驳回此报价吗？</label>
                <form id="form-confirm" class="form-horizontal" role="form">
                    <input type="hidden" name="quoteId">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">驳回意见</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="appRemark" placeholder="请输入驳回意见">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-submit">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </button>
            </div>
        </div>
    </div>
</div>
<section class="content-header">
    <h1>审核报价单
    </h1>
    <h4 style="margin:10px 0px 0px 0px">[[${quotationMain.qttBatchRemk}]]
    </h4>
</section>
<section class="content" style="padding:0px 15px 15px 15px">
    <form id="queryForm" method="post" class="form-horizontal" role="form" enctype="multipart/form-data">
        <input type="hidden" id="quoteId" name="quoteId" th:value="${quotationMain.quoteId}">
        <input type="hidden" id="quoteTaskId" name="quoteTaskId" th:value="${quotationMain.quoteTaskId}">
        <div class="col-lg-pull-12">
            <table class="head-table" style="width: 100%;">
                <tbody style="width: 100%">
                <tr style="border-width:0 0 2px 0;border-style: solid; border-color: #000;">
                    <td style="width: 100%;text-align: center" colspan="3">
                        <div style="display: inline-block;margin-top: 5px">
                            <span style="letter-spacing: 12px;display: block;line-height: 20px">&nbsp;辽宁忠旺机械设备制造有限公司</span>
                            <span style="display: block;font-size: 12px; letter-spacing: 8px; line-height: 20px">www.zhongwangjx.com</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="font-size: 30px; font-weight:bold; height:50px; letter-spacing: 4px;width: 100%;text-align: center"
                        colspan="3">
                        报&nbsp;&nbsp;价&nbsp;&nbsp;单
                    </td>
                </tr>
            </table>
            <table class="info-table" style="margin:15px 0px 15px 0px">
                <tbody>
                <tr class="info-row">
                    <td colspan="2" style="text-align: left;font-weight: bold;font-size: 14px">
                        买方信息：
                    </td>
                    <td style="text-align: left;font-weight: bold;font-size: 14px">
                        卖方信息：
                    </td>
                </tr>
                <tr class="info-row">
                    <td class="left-part-2">
                        <p class="info-p-left" style="text-align:left;padding: 0"
                           th:text="${'买方名称：'+quotationMain.consumerName}"></p>
                    </td>
                    <td class="middle-part"></td>
                    <td class="right-part-2">
                        <p class="info-p-right" style="padding: 0;text-align: left"
                           th:text="${'卖方名称：'+quotationMain.supplierName}"></p>
                    </td>
                <tr class="info-row">
                    <td class="left-part-2">
                        <p class="info-p-left" style="text-align:left;padding: 0"
                           th:text="${'买方联系人：'+quotationMain.consumerAttn}"></p>
                    </td>
                    <td class="middle-part"></td>
                    <td class="right-part-2">
                        <p class="info-p-right" style="padding: 0;text-align: left"
                           th:text="${'卖方联系人：'+quotationMain.supplierAttn}"></p>
                </tr>
                <tr class="info-row">
                    <td class="left-part-2">
                        <p class="info-p-left" style="text-align:left;padding: 0"
                           th:text="${'买方电话：'+quotationMain.consumerTel}"></p>
                    </td>
                    <td class="middle-part">
                    </td>
                    <td class="right-part-2">
                        <p class="info-p-right" style="padding: 0;text-align: left"
                           th:text="${'卖方电话：'+quotationMain.supplierTel}"></p>
                    </td>
                </tr>
                <tr class="info-row">
                    <td class="left-part-2">
                        <p class="info-p-right" style="text-align:left;padding: 0"
                           th:text="${'买方邮箱：'+quotationMain.consumerEmail}"></p>
                    </td>
                    <td class="middle-part">
                    </td>
                    <td class="right-part-2">

                        <p class="info-p-right" style="padding: 0;text-align: left"
                           th:text="${'卖方邮箱：'+quotationMain.supplierEmail}"></p>
                </tr>
                </tbody>
            </table>
            <table class="quotationTable" style="width: 100%" id="table">
                <thead>
                <tr>
                    <td colspan="13" style="font-size:14px;font-weight: normal;border: 0px;text-align: left">
                        1.价格
                    </td>
                </tr>
                <tr>
                    <td style="width: 4%;BORDER-left: 1.5px solid;">序号</td>
                    <td style="width: 16%;">物料名称</td>
                    <td style="width: 11%;">项目名称</td>
                    <td style="width: 10%;">规格型号</td>
                    <td style="width: 5%;">数量</td>
                    <td style="width: 5%;">单位</td>
                    <td style="width: 6%;">不含税</br>单价</td>
                    <td style="width: 6%;">不含税</br>总价(元)</td>
                    <td style="width: 5%;">税率%</td>
                    <td style="width: 6%;">税额</br>(元)</td>
                    <td style="width: 6%;">含税</br>单价</td>
                    <td style="width: 7%;">含税</br>总金额(元)</td>
                    <td style="width: 13.5%;">备注</td>
                </tr>
                </thead>
                <tbody>
                <tr th:each="QuotationSublistModel : ${qtts}">
                    <td class="td" th:text="${QuotationSublistModelStat.count}"></td>
                    <td class="td" th:text="${QuotationSublistModel.proName}"></td>
                    <td class="td">
                        <div name = proNames th:text="${QuotationSublistModel.proNames}" th:id="'proNames_' + ${QuotationSublistModelStat.count}" >
                        </div>
                    </td>
                    <td class="td" th:text="${QuotationSublistModel.proType}"></td>
                    <td class="td" th:text="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(QuotationSublistModel.proQty)}"></td>
                    <td class="td" th:text="${QuotationSublistModel.proUnit}"></td>
                    <td class="td" th:text="${QuotationSublistModel.unitPrice}"></td>
                    <td class="td" th:text="${QuotationSublistModel.totalPrice}"></td>
                    <td class="td" th:text="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(QuotationSublistModel.taxRate)}"></td>
                    <td class="td" th:text="${QuotationSublistModel.taxAmount}"></td>
                    <td class="td" th:text="${QuotationSublistModel.unitPriceTaxIncluded}"></td>
                    <td class="td" th:text="${QuotationSublistModel.totalPriceTaxIncluded}"></td>
                    <td class="td" th:text="${QuotationSublistModel.remark}"></td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="3" style="text-align:center;font-weight: bold;line-height: 200%">
                        合同总金额（元）
                    </td>
                    <td colspan="3" style="text-align:center;font-weight: bold;line-height: 200%" th:text="${quotationMain.totalAmountIncludedTax}">
                    </td>
                    <td colspan="4" style="text-align:center;font-weight: bold;line-height: 200%">
                        合同总金额大写
                    </td>
                    <td colspan="3" style="text-align:center;font-weight: bold;line-height: 200%" th:text="${'人民币'+ quotationMain.totalAmtIncTaxInWords + '（含'+ T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(qtts.get(0).taxRate) +'%增值税）'}">
                    </td>
                </tr>
                <tr style="border:0px;line-height: 22px">
                    <td colspan="13" style="text-align: left;border:0px; font-size: 14px;line-height: 30px">
                        以上价格包含：
                        <input type="checkbox" name="design" style="margi-n-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.design}" th:attr ="checked= ${quotationMain.design == 1 ? true:false}">&thinsp;设计&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="material" style="margin-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.material}" th:attr ="checked= ${quotationMain.material == 1 ?true:false}">&thinsp;材料&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="manufature" style="margin-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.manufature}" th:attr ="checked= ${quotationMain.manufature == 1 ?true:false}">&thinsp;制造&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="packg" style="margin-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.packg}" th:attr ="checked= ${quotationMain.packg == 1 ?true:false}">&thinsp;包装&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="transport" style="margin-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.transport}" th:attr ="checked= ${quotationMain.transport == 1 ?true:false}">&thinsp;运输
                        <span th:if="${quotationMain.transMethod != null}" >[[${quotationMain.transMethod}]]
                        </span>
                        </input>
                        <input type="checkbox" name="install" style="margin-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.install}" th:attr ="checked= ${quotationMain.install == 1 ?true:false}">&thinsp;安装&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="debug" style="margin-top: 0px;vertical-align: middle" onclick="return false;" th:value="${quotationMain.debug}" th:attr ="checked= ${quotationMain.debug == 1 ?true:false}">&thinsp;调试</input>
                    </td>
                </tr>
                <tr style="border:0px;line-height: 22px">
                    <td colspan="13" style="text-align: left;border:0px; font-size: 14px" th:text="'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+${quotationMain.excludeItem}">
                    </td>
                </tr>
                </tfoot>
            </table>
            <table class="bottom" style="width: 100%; margin: 15px 0px 1px 0px">
                <thead>
                <tr>
                    <td colspan="9" style="font-size:14px;font-weight: normal;border: 0px;text-align: left">
                        2.付款
                    </td>
                </tr>
                <tr>
                    <td style="width: 5%;BORDER-left: 1.5px solid;">序号</td>
                    <td style="width: 12%;">节点</td>
                    <td colspan="2" style="width: 30%;">条件</td>
                    <td style="width: 10%;">比例%</td>
                    <td colspan="2" style="width:15%;">金额</td>
                    <td colspan="2"style="width:22%;">方式</td>
                </tr>
                </thead>
                <tbody>
                <tr th:each="QuotationPayment : ${payItems}">
                    <td class="td" th:text="${QuotationPaymentStat.count}"></td>
                    <td class="td" th:text="${QuotationPayment.payItemName}"></td>
                    <td colspan="2" class="td" th:text="${QuotationPayment.payCondition}"></td>
                    <td class="td" th:text="${QuotationPayment.payPercent}"></td>
                    <td colspan="2" class="td" th:text="${QuotationPayment.payAmount}"></td>
                    <td colspan="2" class="td" th:text="${QuotationPayment.payMethodName}"></td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="9"  style="font-size: 14px; border:0px;text-align: left">
                        <p id="quoteBottomDesc" name="quoteBottomDesc" readonly="readonly" th:text="${quotationMain.quoteBottomDesc}"
                           style="height: auto; padding: 0; white-space: pre-wrap; background:none;margin-bottom: 0px; max-width: 100%; min-width: 100%;">
                        </p>
                    </td>
                </tr>
                <tr th:if="${quotationMain.cosType == 2}">
                    <td   colspan="9" style="font-size: 14px;border: 0px;text-align: left">
                        7.审核
                    </td>
                </tr>
                <tr th:if="${quotationMain.cosType == 2}">
                    <td colspan="2" style="font-size: 14px;border: 0px;text-align: left">
                        制&nbsp;&nbsp;&nbsp;&thinsp;表&nbsp;&nbsp;&nbsp;&thinsp;人：
                    </td>
                    <td style="width: 15%;font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                        销售科：
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                        机械设计院：
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                </tr>
                <tr th:if="${quotationMain.cosType == 2}">
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                        生产运营部：
                    </td>
                    <td style="width: 15%;font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                        董事长：
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                        集团财务&nbsp;&nbsp;&nbsp;&thinsp;：
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                </tr>
                <tr>
                    <td colspan="8" style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                        制表日期：
                    </td>
                </tr>
            </table>
            <div class="row" style="margin-top: 15px">
                <div class="box"style="padding:0px 0px 0px 0px">
                    <div class="col-md-12" style="padding: 0">
                        <p style="margin:0px 0px 1px 0px; font-size: 14px; line-height: 25px; font-weight: bold; margin-top: 10px">附件信息：</p>
                    </div>
                    <table id="bootstrap-table1" style="padding-top: 0;"></table>
                </div>
                <div class="box"style="padding:0px 0px 0px 0px"  th:if="${not #lists.isEmpty(appList)}">
                    <div class="col-md-12" style="padding: 0; margin: 20px 0 0 0 ">
                        <p style="margin:0px 0px 1px 0px; font-size: 14px; font-weight: bold">审核信息：</p>
                    </div>
                    <table class="table" >
                        <tbody>
                        <tr>
                            <th class="text-center">审批人</th>
                            <th  class="text-center">审批时间</th>
                            <th class="text-center">审批结果</th>
                            <th  class="text-center">审批意见</th>
                        </tr>
                        <tr th:each="appList:${appList}">
                            <td th:text="${appList.name}"></td>
                            <td th:text="${#dates.format(appList.appTime, 'yyyy-MM-dd')}"></td>
                            <td th:text="${appList.projectName}"></td>
                            <td th:text="${appList.appRemark}"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>

            <div  class="col-md-12"  th:if="${(quotationMain.quoteStatus == 2 ||quotationMain.quoteStatus == 3) && quotationMain.nowNode == sysUserModel.verifyInfoId}"  style="margin: 10px 0 0 0; padding:0">
                <!--<div  class="form-group" style="margin: 0px 0 0 0">-->
                    <!--<div class="col-md-12" style="padding: 0">-->
                    <!--<p style="margin:0px 0px 1px 0px; font-size: 14px; line-height: 25px; font-weight: bold; margin-top: 10px">审核意见：</p>-->
                    <!--</div>-->
                    <!--<div class="col-md-10" style="padding:0">-->
                        <!--<input  type="text" name="appRemark" class="form-control">-->
                    <!--</div>-->
                    <div  style="padding:0;margin-top: 5px">
                        <button type="button" class="btn btn-danger pull-right"   onclick="rejectQuotation()"  id="btn-rej-qtt">
                            驳回
                        </button>
                        <button type="button" class="btn btn-success pull-right" style="margin-right: 10px" id="btn-app-qtt">
                            通过
                        </button>
                    </div>
                <!--</div>-->
            </div>
        </div>
        </div>
    </form>
</section>
<div th:include="include :: footer"></div>

<script th:inline="javascript">

    /**
     *驳回报价
     */
    function rejectQuotation() {
        $("#form-confirm  input[name ='quoteId']").val($("#quoteId").val());
        js.modal.open("modal-confirm");
    }
    var table1;
    var table;
    $(function () {
        var obj = [[${quotationMain}]];
        $('#quoteBottomDesc').html(obj.quoteBottomDesc);
        //将多个项目名换行
        var objectModel = [[${qtts}]];
        for(i = 1; i <= objectModel.length; i++){
            if(objectModel[i-1].proNames != null){
                var proNames = objectModel[i-1].proNames;
                var t = proNames.split(',').join('<br>');
                $("#proNames_"+i).html(t);
            }
        }
        /**
         *加载附件列表
         */
        table1 = js.table.init({
            id: 'bootstrap-table1',
            url: ctx + "quoteManage/createQuotation/fileList",
            showColumns: false,
            showExport: false,
            pagination: false,
            queryData: {quoteId: $("#quoteId").val()},
            onLoadSuccess: function (data) {
                var dataSource = $('#bootstrap-table1').bootstrapTable('getData', true);
            },
            columns: [
                {
                    title: '序号', field: 'id', width: '60',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '文件名称', field: 'fileName', width: '350'},
                {
                    title: '文件类型', field: 'fileType', width: '150',
                    formatter: function (value, row, index) {
                        if (row.fileType == 1) {
                            return '报价单扫描件';
                        } else if (row.fileType == 2) {
                            return '报价其他文件';
                        }
                    }
                },
                {title: '上传日期', field: 'fileUploadDate', width: '150'},
                {title: '上传者', field: 'userName', width: '150'},
                {title: '文件备注', field: 'fileComment', width: '250'},
                {
                    title: '操作', width: '80',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (hasP("quo:await:download")) {
                        actions.push('<a class="btn btn-info btn-xs" href="' + row.fileUrl + '" target="_blank"> 下载</a>');
                        }
                        return actions.join('');
                    }
                }
            ]
        });


        /**
         * 审核通过
         */
        $("#btn-app-qtt").click(function () {
            js.modal.confirm("确认审核通过？", function () {
                js.submit({
                    url: ctx + "quoteManage/quoteApprove/appQtt",
                    data: new FormData($("#queryForm")[0]),
                    success: function (result) {
                        if (result.type === web_status.SUCCESS) {
                            js.modal.success(result.msg);
                            window.parent.getItemCount();
                            setTimeout(function () {
                                location.href = ctx + "quoteManage/quoteApprove/page";
                            }, 700);
                        } else {
                            js.modal.warning(result.msg);
                        }
                    }
                });
            });
        });

        /**
         * 审核驳回
         */
        $("#btn-submit").click(function () {
                js.submit({
                    url: ctx + "quoteManage/quoteApprove/rejQtt",
                    data: new FormData($("#form-confirm")[0]),
                    success: function (result) {
                        if (result.type === web_status.SUCCESS){
                            js.modal.success(result.msg);
                            window.parent.getItemCount();
                            setTimeout(function () {
                                location.href = ctx + "quoteManage/quoteApprove/page";
                            }, 700);
                        }else {
                            js.modal.warning(result.msg);
                        }
                    }
                });
        });


        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        js.modal.hideEvent("modal-confirm", function () {
            js.reset("form-confirm");
        });
    });
</script>
</body>
</html>

